/*
 * FileState.java
 *
 * Created on 14 April 2007, 21:55
 *
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */

package org.cardcopier.file;

import java.io.File;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;

/**
 *
 * @author Mark
 */
public class FileState {
    
    private final File sourceFile;
    private final File destinationFile;
    
    public FileState(File sourceFile, File destinationFile) {
        this.sourceFile = sourceFile;
        this.destinationFile = destinationFile;
    }
    
    public String getName() {
        return sourceFile.getName();
    }

    public boolean fileExistsInDestination() {
        return destinationFile.exists();
    }

    public File getSourceFile() {
        return sourceFile;
    }

    public File getDestinationFile() {
        return destinationFile;
    }
    
    public Date getLastModified() {
        return new Date(sourceFile.lastModified());
    }
    
    public long getFileLengthInBytes() {
        return sourceFile.length();
    }
    
    public String toString() {
        ByteSizeFormatter byteSizeFormat = new ByteSizeFormatter();
        DateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss");

        String lastModified = dateFormat.format(getLastModified());
        String fileSize = byteSizeFormat.format(getFileLengthInBytes());
	return sourceFile.getName() + " " + fileSize + " " + lastModified;
    }
}
